<?php

class App_Access_Acl extends Zend_Acl
{
	public function __construct($path = null)
	{
		if($path == null){
			$path = APPLICATION_PATH . '/configs/acl.ini';
		}
		$config = new Zend_Config_Ini($path);
		$roles = $config->acl->roles->toArray();
		$this->_addRoles($roles);
		//$this->deny();
	}
	protected function _addRoles($roles)
	{
		foreach($roles as $role => $parents){
			if(!$this->hasRole($role)){
				if(empty($parents)){
					$parents = null;
				}
				else{
					$parents = explode(',', $parents);
				}
				$this->addRole(new Zend_Acl_Role($role), $parents);
			}
		}
	}
}